<%@page import="cn.jhc.dao.ShowmvDAO"%>
<%@page import="cn.jhc.bean.ShowmvBean"%>
<%@page import="cn.jhc.dao.ConnectionFactory"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/houtai.css"></link>
<script type="text/javascript">
function MM_popupMsg(msg) {
     alert(msg);
}
</script>
<title>社团管理平台</title>
</head>
<body>
	<%
		int CurrentPage = 1;
		int intPageCount;
		if (request.getParameter("page") != null)
			CurrentPage = Integer.parseInt(request.getParameter("page"));
		if (CurrentPage < 1)
			CurrentPage = 1;
		int newsCount=10;
		int MsgCount;
	%>
	<div id="wrapper">
		<jsp:include page="./houtai_header.jsp"></jsp:include>
		<div id="left">
			<div class="button2"><a href="houtai_monthstar.jsp">本月之星评选</a></div>
			<div class="button"><a href="houtai_lastMonthStar.jsp">历届每月之星</a></div>
		</div>
		<div id="right">
			<div id="right_top">
				<a>所在位置： 每月之星&gt;本月之星评选</a>
			</div>
			<%
				ArrayList<ShowmvBean> s = new ArrayList<ShowmvBean>();
				ShowmvDAO dao = new ShowmvDAO();
				dao.setCon(ConnectionFactory.getConnection());
				s = dao.getAllTitle(CurrentPage,newsCount);
				request.setAttribute("title", s);
			%>
			<%
				dao.setCon(ConnectionFactory.getConnection());
				intPageCount = dao.getCount(newsCount);
				if (CurrentPage > intPageCount)
					CurrentPage = intPageCount;
			%>
			<div id="right_news">
				<table width="100%">
					<tr>
						<th height="25">每月之星候选</th>
						<th>发布时间</th>
						<th>赞成</th>
						<th>反对</th>
						<th>留言数</th>
						<th colspan="2">操作</th>
					</tr>
					<%
						ArrayList list = (ArrayList) request.getAttribute("title");
							if (list != null) {
								for (int i = 0; i < list.size(); i++) {
									ShowmvBean tit = (ShowmvBean) list.get(i);
					%>
						<tr>
							<td width="60%" height="25"><a
								href="showonemv.jsp?id=<%=tit.getId()%>"><%=tit.getTitle()%></a></td>
							<td><div align="center"><%=tit.getDate()%></div></td>
							<td><div align="center"><%=tit.getAgreed()%></div></td>
							<td><div align="center"><%=tit.getAgainst()%></div></td>
							<%
								dao.setCon(ConnectionFactory.getConnection());
								MsgCount = dao.getMsgCount(tit.getId());
							%>
							<td><div align="center"><%=MsgCount%></div></td>
							<td><div align="center"><a href="./deleteMV.do?id=<%=tit.getId()%>" onclick="MM_popupMsg('删除成功！')">删除</a></div></td>
							<td><div align="center"><a href="./houtai_StarYes.do?id=<%=tit.getId()%>" onclick="MM_popupMsg('评选为每月之星！')">每月之星</a></div></td>
						</tr>
					<% 
						}
							}
					%>
				</table>
				<div align="right">
					<a>第<%=CurrentPage%>页 共<%=intPageCount%>页
					</a> <a href="houtai_monthstar.jsp?page=<%=1%>">首页</a>
					<%
						if (CurrentPage > 1) {
					%>
					<a href="houtai_monthstar.jsp?page=<%=CurrentPage - 1%>">上一页</a>
					<%
						} else {
					%>
					上一页
					<%
						}
					%>
					<%
						if (CurrentPage >= intPageCount) {
					%>
					下一页
					<%
						} else {
					%>
					<a href="houtai_monthstar.jsp?page=<%=CurrentPage + 1%>">下一页</a>
					<%
						}
					%>
					<a href="houtai_monthstar.jsp?page=<%=intPageCount%>">末页</a>
				</div>
			</div>
		</div>
	</div>
</body>
</html>